<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/4
 * Time: 15:09
 */

function code($str,$len,$type){
    $code = '';
   if ($type == 1){
       for ($i=0;$i<$len;$i++){
           $code.= $str[rand(0,9)];
       }
   }

   elseif($type == 2){
        for ($i=0;$i<$len;$i++){
            $code.=$str[rand(10,35)];
        }
    }

    elseif($type == 3){
        for ($i=0;$i<$len;$i++){
            $code.=$str[rand(0,35)];
        }
    }
    return $code;
}

